﻿using System;
using System.IO;
using System.Windows.Forms;

namespace Magitek.Settings
{
    public partial class SettingsForm : Form
    {
        public SettingsForm()
        {
            InitializeComponent();
        }
        private Form _jobform;
        private Form _generalform;
        private Form _healingmanagerform;
        private void btnJobSettings_Click(object sender, EventArgs e)
        {
            if (_jobform == null || _jobform.IsDisposed || _jobform.Disposing)
                _jobform = new ClassSettingsForm();

            _jobform.ShowDialog();     
        }
        private void checkBox1_CheckedChanged(object sender, EventArgs e)
        {
            Magitek.WindowSettings.AlwaysOnTop = checkBox1.Checked;
            TopMost = Magitek.WindowSettings.AlwaysOnTop;
        }
        private void button1_Click(object sender, EventArgs e)
        {
            if (_generalform == null || _generalform.IsDisposed || _generalform.Disposing)
                _generalform = new GeneralSettingsForm();

            _generalform.ShowDialog();    
        }
        private void SettingsForm_Load(object sender, EventArgs e)
        {
            checkBox1.Checked = Magitek.WindowSettings.AlwaysOnTop;
            TopMost = Magitek.WindowSettings.AlwaysOnTop;
            chkInterrupt.Checked = Magitek.WindowSettings.InterruptCast;
            chkAutoTarget.Checked = Magitek.WindowSettings.AutoTarget;
            tmrUpdateForm.Start();

        }

        private void SettingsForm_Closed(object sender, EventArgs e)
        {
            Magitek.WindowSettings.Save();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            if (_healingmanagerform == null || _healingmanagerform.IsDisposed || _healingmanagerform.Disposing)
                _healingmanagerform = new HealingManagerForm();

            _healingmanagerform.ShowDialog();  
        }
        private void chkInterrupt_CheckedChanged(object sender, EventArgs e)
        {
            Magitek.WindowSettings.InterruptCast = chkInterrupt.Checked;
            Magitek.WindowSettings.Save();
        }
        private void checkBox2_CheckedChanged(object sender, EventArgs e)
        {
            Magitek.WindowSettings.AutoTarget = chkAutoTarget.Checked;
            Magitek.WindowSettings.Save();
        }

        private void tmrUpdateForm_Tick(object sender, EventArgs e)
        {
            if (Magitek.WindowSettings.AOEEnabled)
                lblAOEBackground.Text = "AOE Mode Enabled";

            if (!Magitek.WindowSettings.AOEEnabled)
                lblAOEBackground.Text = "AOE Mode Disabled";
        }
    }
}
